package com.xm.zcf.util;

import java.util.List;

/**
 * Created by Administrator on 2017/3/20.
 */
public class PageBean<E> {
    private Integer page;   //当前页
    private Integer limit;  //一页中有多少条数据
    private Integer count;  //总共的记录数有多少条
    private List<E> list;   //一页中数据的记录列表
    private Integer beginIndex; //开始索引
    private Integer endIndex; //结束索引
    private Integer pageCount; //总页数

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public List<E> getList() {
        return list;
    }

    public void setList(List<E> list) {
        this.list = list;
    }

    public Integer getBeginIndex() {
        return beginIndex;
    }

    public void setBeginIndex(Integer beginIndex) {
        this.beginIndex = beginIndex;
    }

    public Integer getEndIndex() {
        return endIndex;
    }

    public void setEndIndex(Integer endIndex) {
        this.endIndex = endIndex;
    }

    public Integer getPageCount() {
        return pageCount;
    }

    public void setPageCount(Integer pageCount) {
        this.pageCount = pageCount;
    }

    public PageBean(Integer page, Integer limit, Integer count, List<E> list) {
        this.page = page;
        this.limit = limit;
        this.count = count;
        this.list = list;
        pageCount=count/limit;
        if((count%limit)>0){
            pageCount++;
        }
        if(pageCount<10){
            beginIndex=1;
            endIndex=pageCount;
        }else{
            beginIndex=page-4;
            endIndex=page+5;
            if(beginIndex<=0){
                beginIndex=1;
                endIndex=10;
            }else
                if(endIndex>pageCount){
                    beginIndex=pageCount-9;
                    endIndex=pageCount;
            }
        }
    }

    public PageBean(){

    }
}
